package org.perla.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 */
@Entity
@Table(name = "crackmeter")
@NamedQueries({
    @NamedQuery(name = "Crackmeter.findAll", query = "SELECT c FROM Crackmeter c"),
    @NamedQuery(name = "Crackmeter.findByIdSensore", query = "SELECT c FROM Crackmeter c WHERE c.crackmeterPK.idSensore = :idSensore"),
    @NamedQuery(name = "Crackmeter.findByTimestamp", query = "SELECT c FROM Crackmeter c WHERE c.crackmeterPK.timestamp = :timestamp"),
    @NamedQuery(name = "Crackmeter.findByCrackMeter", query = "SELECT c FROM Crackmeter c WHERE c.crackMeter = :crackMeter"),
    @NamedQuery(name = "Crackmeter.findByIdNodo", query = "SELECT c FROM Crackmeter c WHERE c.crackmeterPK.idNodo = :idNodo")})
public class Crackmeter implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CrackmeterPK crackmeterPK;
    @Basic(optional = false)
    @Column(name = "crackMeter")
    private short crackMeter;

    public Crackmeter() {
    }

    public Crackmeter(CrackmeterPK crackmeterPK) {
        this.crackmeterPK = crackmeterPK;
    }

    public Crackmeter(CrackmeterPK crackmeterPK, short crackMeter) {
        this.crackmeterPK = crackmeterPK;
        this.crackMeter = crackMeter;
    }

    public Crackmeter(String idSensore, long timestamp, String idNodo) {
        this.crackmeterPK = new CrackmeterPK(idSensore, timestamp, idNodo);
    }

    public CrackmeterPK getCrackmeterPK() {
        return crackmeterPK;
    }

    public void setCrackmeterPK(CrackmeterPK crackmeterPK) {
        this.crackmeterPK = crackmeterPK;
    }

    public short getCrackMeter() {
        return crackMeter;
    }

    public void setCrackMeter(short crackMeter) {
        this.crackMeter = crackMeter;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (crackmeterPK != null ? crackmeterPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Crackmeter)) {
            return false;
        }
        Crackmeter other = (Crackmeter) object;
        if ((this.crackmeterPK == null && other.crackmeterPK != null) || (this.crackmeterPK != null && !this.crackmeterPK.equals(other.crackmeterPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.perla.entities.Crackmeter[crackmeterPK=" + crackmeterPK + "]";
    }

}
